int countPairs(int* nums, int numsSize, int k)
{
    //1 <= nums.length <= 100
    int a,b;
    int count = 0;
    for(a = 0; a < numsSize;a++)
    {
        for(b = a + 1; b < numsSize;b++)
        {
            if(nums[a] == nums[b])
            {
                if((a * b ) % k == 0)
                {
                    count++;
                }
            }
        }
    }
    return count;
}

int main()
{
    int nums[7] = {3,1,2,2,2,1,3}, k = 2;
    int ret = countPairs(nums, 7, k);
    printf("%d", ret);
}